package com.stackoverflow;

import java.util.List;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class TopTags extends ListActivity implements OnClickListener {
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
	    setContentView(R.layout.stringlist);
	    
	    List<String> listItems = Retriever.getInstance().getTopTags();
	    
	    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, listItems.toArray(new String[listItems.size()]));
		setListAdapter(adapter);
		
		ListView mainListView = getListView();
        mainListView.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView adapterView, View view, int position, long id) {
            	// Get the question ID and pass it to the answer list activity
            	Intent i = new Intent(TopTags.this, QuestionList.class);
            	ArrayAdapter<String> adapter = (ArrayAdapter<String>) getListAdapter();
            	String tagString = adapter.getItem(position);

            	i.putExtra("tagName", tagString);
            	startActivity(i);
            }
        });
	}
	
	public void onClick(View v) {
		
	}
}
